<?php
// No direct access
defined('_JEXEC') or die;

class AppcategorysHelper
{
	public static $extension = 'com_appcategorys';

	/**
	 * Configure the Linkbar.
	 *
	 * @param	string	$vName	The name of the active view.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public static function addSubmenu($vName)
	{
		JSubMenuHelper::addEntry(
			JText::_('Danh mục App'),
			'index.php?option=com_appcategorys&view=appcategorys',
			$vName == 'appcategorys'
		);
                //Goi com_app
		JSubMenuHelper::addEntry(
			JText::_('Appstore'),
			'index.php?option=com_appcategorys&view=appcategorys',
			$vName == 'appcategorys');
		JSubMenuHelper::addEntry(
			JText::_('Appstore nổi bật'),
			'index.php?option=com_appcategorys&view=featured',
			$vName == 'featured'
		);
	}

	/**
	 * Gets a list of the actions that can be performed.
	 *
	 * @param	int		The category ID.
	 * @param	int		The article ID.
	 *
	 * @return	JObject
	 * @since	1.6
	 */
	public static function getActions($categoryId = 0, $appcategoryId = 0)
	{
		// Reverted a change for version 2.5.6
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($appcategoryId) && empty($categoryId)) {
			$assetName = 'com_appcategorys';
		}
		elseif (empty($appcategoryId)) {
			$assetName = 'com_appcategorys.appcategory.'.(int) $categoryId;
		}
		else {
			$assetName = 'com_appcategorys.appcategory.'.(int) $appcategoryId;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
}
